(function() {
	
	Cube.Array = {
		singleton: true,
		
		/**
		 * Slice array
		 * 
		 * @param {Array} array The array (or arguments object).
	     * @param {Number} begin The index at which to begin. Negative values are offsets from
	     * the end of the array.
	     * @param {Number} end The index at which to end. The copied items do not include
	     * end. Negative values are offsets from the end of the array. If end is omitted,
	     * all items up to the end of the array are copied.
	     * @return {Array} The copied piece of the array.
		 */
		slice: ([1,2].slice(1, undefined).length ?
	        function (array, begin, end) {
	            return Array.prototype.slice.call(array, begin, end);
	        } :
	        function (array, begin, end) {
	            if (typeof begin === 'undefined') {
	                return Array.prototype.slice.call(array);
	            }
	            if (typeof end === 'undefined') {
	                return Array.prototype.slice.call(array, begin);
	            }
	            return Array.prototype.slice.call(array, begin, end);
	        }
	    ),
	    
	    isArray: function(object) {
	    	if (object instanceof Array)
	    	{
	    		return true;
	    	}
	    	
	    	return false;
	    },
	    
	    /**
	     * Iterate over each item of an array/object. It will automatically pick the fastest way to iterate over your array or object.
	     *  
	 	 * @param {Object} array
	 	 * @param {Object} fn
	 	 * @param {Object} scope
	     */
	    each: function(array, fn, scope) {
	    	if (Cube.Array.isArray(array))
	    	{
	    		for (i = 0; i < array.length; i++)
	    		{
	    			fn.apply(scope, [array[i], i]);
	    		}
	    	}
	    	else
	    	{
	    		for (i in array)
	    		{
	    			fn.apply(scope, [array[i], i]);
	    		}
	    	}
	    }
	};
	
	Cube.each = Cube.Array.each;
	
})();
